package com.example.administrator.myapplication;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.RotateAnimation;
import android.widget.TextView;


public class MainActivity extends AppCompatActivity {
        TextView tv_zhuye;
    Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 100){
                Intent intent = new Intent(MainActivity.this, Zhuye.class);
                startActivity(intent);
                finish();
            }
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv_zhuye = (TextView) findViewById(R.id.tv_zhuye);
        AlphaAnimation animation = new AlphaAnimation(0.5f, 0.0f);
        animation.setDuration(1000);
        tv_zhuye.startAnimation(animation);
        RotateAnimation rotateAnimation = new RotateAnimation(0, 360, tv_zhuye.getWidth() / 2, tv_zhuye.getHeight() / 2);
        rotateAnimation.setDuration(1000);
        tv_zhuye.startAnimation(rotateAnimation);
        new Thread(){
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                    Message message = new Message();
                    message.what = 100;
                    handler.sendMessage(message);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }


}
